<template>
  <view class="mine-container" :style="{ height: `${windowHeight}px` }">
    <!-- <view class="header-section">
      <view class="flex justify-between">
        <uni-easyinput :styles="styles" type="textarea" v-model="linkUrl" placeholder="此处粘贴要提取的视频链接"> </uni-easyinput>
      </view>
      <view class="operateGroup">
        <view style="width: 100%">
          <button type="primary" @click="clearLink">重置链接</button>
        </view>
      </view>
      <view class="analysis">
        <button type="primary" @click="analysisLink">提取解析</button>
      </view>
    </view> -->
    <view class="menu">
      <view class="menu-item" v-for="(item, index) in menuList" :key="index" @click="jump(item)">
        <view class="title">{{ item.title }}</view>
        <view class="content">{{ item.content }}</view>
      </view>
    </view>

    <view class="footer flexCenter">
      <view class="btn">联系客服赠送积分</view>
      <button open-type="contact" class="online-service">联系客服赠送积分</button>
    </view>
  </view>
</template>

<script>
import { analysisUrl } from '@/api/common.js'
export default {
  data() {
    return {
      name: this.$store.state.user.name,
      linkUrl: '',
      // linkForm: {
      // 	linkUrl: ''
      // },
      styles: {
        borderColor: '#DCDCDC'
      },
      menuList: [
        {
          title: '去水印',
          content: '支持视频、图集',
          url: '/pages/watermark/index'
        },
        {
          title: '文案提取',
          content: '视频、音频提取文案',
          url: '/pages/textExtraction/index'
        },
        {
          title: '智能配音',
          content: '拥有丰富的播音员',
          url: '/pages/dub/index'
        }
        // {
        //   title: '卡通头像',
        //   content: '卡通头像',
        //   url: '/pages/cartoonAvatar/index'
        // }
      ]
    }
  },
  computed: {
    windowHeight() {
      return uni.getSystemInfoSync().windowHeight - 50
    }
  },
  onReady() {
    // this.$refs.linkForm.setRules(this.rules)
  },
  methods: {
    // 页面跳转
    jump(item) {
      uni.navigateTo({
        url: item.url
      })
    },
    // 清除链接
    clearLink() {
      this.linkUrl = ''
    },
    // 粘贴链接
    pasteLink() {
      uni.getClipboardData({
        success: function (res) {
          //进行相应的操作后把粘贴板内容清空，防止每次进入app都会做此操作，如            果项目有需求可以不用
          uni.setClipboardData({
            data: '',
            showToast: false
          })
        },
        fail: function (err) {
          console.log(err)
        }
      })
    },
    // 解析链接
    analysisLink() {
      if (!this.name) {
        uni.showModal({
          title: '温馨提示',
          content: '您未登录，请前往登录',
          cancelText: '暂不登录',
          confirmText: '立即登录',
          success: function (res) {
            if (res.confirm) {
              uni.switchTab({ url: '/pages/mine/index' })
              // console.log(111)
              // uni.hideToast();
            } else if (res.cancel) {
              // uni.navigateBack()
              uni.hideToast()
            }
          }
        })
      }
      if (this.linkUrl == '') {
        uni.showToast({
          icon: 'none',
          title: '请输入链接'
        })
      } else {
        const obj = { url: this.linkUrl }
        analysisUrl(obj).then((res) => {
          // console.log('xxxxxx', res)
        })
      }
      // console.log('analysisUrl', this.linkUrl)
    }
  }
}
</script>

<style lang="scss" scoped>
.mine-container {
  width: 100%;
  height: 100%;
  .header-section {
    height: 500rpx;
    padding: 20rpx 20rpx 20rpx 20rpx;
    background-color: #fffafa;
    color: white;
    .operateGroup {
      display: flex;
      justify-content: space-around;
      margin-top: 20rpx;
    }
    .analysis {
      margin-top: 20rpx;
    }
  }
  .menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 20rpx;
    padding: 20rpx;
    .menu-item {
      background: #fff;
      border-radius: 20rpx;
      padding: 20rpx;
      .title {
        font-size: 28rpx;
      }
      .content {
        font-size: 24rpx;
        margin-top: 10rpx;
        color: #999;
      }
    }
  }
  .footer {
    position: fixed;
    bottom: 20rpx;
    left: 0;
    width: 100%;
    .btn {
      width: 690rpx;
      height: 90rpx;
      line-height: 90rpx;
      text-align: center;
      font-size: 32rpx;
      color: #ffffff;
      background: radial-gradient(0% 70% at 50% 50%, #ff5b24 0%, #bc0a0d 100%);
      border-radius: 20rpx;
    }
    .online-service {
      position: absolute;
      width: 100%;
      padding: 0;
      left: 0;
      opacity: 0;
      z-index: 1;
    }
  }
}
</style>
